var e = getApp();

Page({
    data: {
        active: 0,
        notShow: [ "lifeService", "uidCode", "codePage", "teamSell", "eliteAwardHome", "admarketHome", "Bonus", "extendHelper", "publish_manage", "hireCarManage", "TransHome", "ReplenishmentApply", "DeliveryTerminalApply", "signIndex", "footprintMember", "oilStation", "gduIndex" ],
        plugin: [],
        acindex: 0,
        topHeight: 55,
        currBox: "tab0",
        heightArray: [],
        toview: "",
        isClick: !1,
        poster_center_is_replace: !1
    },
    onLoad: function(e) {
        this.getPlugins();
    },
    getPlugins: function() {
        var t = this, a = e.getNetAddresss("member.member.more-plugins");
        e._getNetWork({
            url: a,
            data: {},
            success: function(e) {
                var a = e.data;
                let arr = [];
                let arr1 = [];
                1 == a.result && (a.data.plugin.forEach(function(e, a) {
                  
                    e.plugin.forEach(function(a, i) {
                        t.data.notShow.indexOf(a.url) >= 0 && e.plugin.splice(i, 1);
                    });
                }),
                a.data.plugin.forEach(item => {
                  if(item.name != "特色业务" && item.name != "商家合作" && item.name != "我的资产" && item.name != "便捷服务"){
                    arr.push(item)
                  }
                }),
                arr.forEach(item => {
                 
                  if(item.name == "互动参与"){
                    let index = item.plugin.findIndex(items => items.title == "二维码")
                    
                    if(index !== -1){
                      item.plugin.splice(index,1)
                    }
                  }
                })
                ,t.setData({
                    // plugin: a.data.plugin || []
                    plugin: arr || []
                }), setTimeout(function() {
                    t.testTabs();
                }, 200));
            }
        });
    },
    getTemplate_1: function() {
        var t = e.getNetAddresss("member.member.getMiniTemplateCorrespond"), a = this;
        e._getNetWork({
            url: t,
            data: {
                small_type: 4
            },
            success: function(e) {
                var t = e.data;
                if (1 == t.result) {
                    for (var i = [], n = 0; n < t.data.length; n++) i.push(t.data[n].template_id);
                    a.setData({
                        TemplateArray_1: i
                    }), wx.requestSubscribeMessage({
                        tmplIds: a.data.TemplateArray_1,
                        success: function(e) {
                            wx.navigateTo({
                                url: "/packageA/member/SupplierCenter/SupplierCenter?uid=" + a.data.supplier_id
                            });
                        },
                        fail: function() {
                            wx.navigateTo({
                                url: "/packageA/member/SupplierCenter/SupplierCenter?uid=" + a.data.supplier_id
                            });
                        }
                    });
                } else wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getTemplate_2: function() {
        var t = e.getNetAddresss("member.member.getMiniTemplateCorrespond"), a = this;
        e._getNetWork({
            url: t,
            data: {
                small_type: 5
            },
            success: function(e) {
                var t = e.data;
                if (1 == t.result) {
                    for (var i = [], n = 0; n < t.data.length; n++) i.push(t.data[n].template_id);
                    a.setData({
                        TemplateArray_2: i
                    }), wx.requestSubscribeMessage({
                        tmplIds: a.data.TemplateArray_2,
                        success: function(e) {
                            wx.navigateTo({
                                url: "/packageC/o2o/storeManage/storeManage"
                            });
                        },
                        fail: function() {
                            wx.navigateTo({
                                url: "/packageC/o2o/storeManage/storeManage"
                            });
                        }
                    });
                } else wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getTemplate_3: function() {
        var t = e.getNetAddresss("member.member.getMiniTemplateCorrespond"), a = this;
        e._getNetWork({
            url: t,
            data: {
                small_type: 6
            },
            success: function(e) {
                var t = e.data;
                if (1 == t.result) {
                    for (var i = [], n = 0; n < t.data.length; n++) i.push(t.data[n].template_id);
                    a.setData({
                        TemplateArray_3: i
                    }), wx.requestSubscribeMessage({
                        tmplIds: a.data.TemplateArray_3,
                        success: function(e) {
                            wx.navigateTo({
                                url: "/packageD/directSeeding/helperLiveList/helperLiveList"
                            });
                        },
                        fail: function() {
                            wx.navigateTo({
                                url: "/packageD/directSeeding/helperLiveList/helperLiveList"
                            });
                        }
                    });
                } else wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    goextension: function() {
        wx.reLaunch({
            url: "/packageG/pages/member/extension/extension"
        });
    },
    pluginGoto: function(e) {
        var t = e.currentTarget.dataset.item, a = t.url;
        "courier" == t.name ? (wx.setStorage({
            key: "couriername",
            data: t.title
        }), wx.navigateTo({
            url: "/packageA/member/" + a + "/" + a
        })) : "supplier" == t.name && "SupplierCenter" == t.url ? this.getTemplate_1() : "extension" == t.url ? this.goextension() : "storeManage" == t.url ? this.getTemplate_2() : "supplier" == t.name ? wx.navigateTo({
            url: "/packageA/member/" + a + "/" + a + "?uid=" + this.data.supplier_id
        }) : "HotelManage" == t.url ? wx.navigateTo({
            url: "/packageA/hotel/HotelManage/HotelManage?title=" + encodeURIComponent("酒店管理")
        }) : "helperLiveList" == t.url ? this.getTemplate_3() : "cloudIndex" == t.url ? wx.navigateTo({
            url: "/packageE/others/cloudwarehouse/cloud_index/cloud_index"
        }) : "collageIndex" == t.url ? wx.navigateTo({
            url: "/packageE/member/collage/collageIndex/collageIndex"
        }) : "m-erweima" == t.name ? this.openQrCode(this.data.dataIs) : t.mini_url && wx.navigateTo({
            url: t.mini_url
        });
    },
    openQrCode: function(e) {
        this.data.poster_center_is_replace ? wx.navigateTo({
            url: "/packageI/newPoster/newPoster"
        }) : this.setData({
            isshow: !0
        });
    },
    taptest: function(e) {
        var t = this, a = e.currentTarget.dataset.ind;
        this.setData({
            acindex: a,
            toview: "ind".concat(a),
            currBox: "tab" + a,
            isClick: !0
        }), setTimeout(function() {
            t.setData({
                isClick: !1
            });
        }, 500);
    },
    bincroll: function(e) {
        if (!this.data.isClick) for (var t = 0; t < this.data.plugin.length; t++) {
            if (this.data.heightArray[1] >= e.detail.scrollTop) {
                this.setData({
                    acindex: 0,
                    currBox: "tab0"
                });
                break;
            }
            if (this.data.heightArray[t] < e.detail.scrollTop && e.detail.scrollTop < this.data.heightArray[t + 1]) {
                this.setData({
                    acindex: t,
                    currBox: "tab" + t
                });
                break;
            }
            if (this.data.heightArray[this.data.plugin.length - 1] <= e.detail.scrollTop) {
                this.setData({
                    acindex: this.data.plugin.length - 1,
                    currBox: "tab" + this.data.plugin.length - 1
                });
                break;
            }
        }
    },
    testTabs: function() {
        for (var e = this, t = [], a = function(a) {
            wx.createSelectorQuery().select("#ind".concat(a)).boundingClientRect(function(i) {
                t.push(i.top - e.data.topHeight), a == e.data.plugin.length - 1 && e.setData({
                    heightArray: t
                });
            }).exec();
        }, i = 0; i < this.data.plugin.length; i++) a(i);
    },
    onReady: function() {},
    onShow: function() {
        var e = wx.getStorageSync("yz_basic_info");
        e.plugin_setting && e.plugin_setting.poster_center && 1 == e.plugin_setting.poster_center.is_open && 1 == e.plugin_setting.poster_center.is_replace && this.setData({
            poster_center_is_replace: !0
        });
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});